# include "ConnectionWindow.h"

ConnectionWindow::ConnectionWindow(QWidget* parent)
{
	this->m_ui.setupUi(this);
	this->setParent(parent);
	this->connect(this->m_ui.messageInput, &QLineEdit::returnPressed, this, &ConnectionWindow::messageInputSubmit);
	this->connect(this->m_ui.connect, &QPushButton::clicked, this, &ConnectionWindow::connectButtonClick);
}

void ConnectionWindow::log(const QString& _message)
{
	this->m_ui.messageTextBox->insertPlainText(_message + "\n");
	// this->m_ui.messageTextBox->setPlainText(_message);
}

void ConnectionWindow::messageInputSubmit() {
	this->log(this->m_ui.messageInput->text());
	emit this->messageInput(this->m_ui.messageInput->text());
	this->m_ui.messageInput->clear();
}

ConnectionWindow::~ConnectionWindow()
{
}

void ConnectionWindow::connectButtonClick()
{
	short port = this->m_ui.connectPort->text().toShort();
	if (port != 0) {
		emit this->connectButton(port);
		/*this->m_ui.localPort->setEnabled(false);
		this->m_ui.login->setEnabled(false);*/
	}
}
